﻿Imports System.IO

Public Class Logging

    Private FileNameValue As String


    Public Property FileName() As String
        Get
            Return FileNameValue
        End Get
        Set(ByVal value As String)
            FileNameValue = value
        End Set
    End Property

    Public Sub New()

    End Sub

    Public Sub New(ByVal FileName As String)
        Me.FileName = FileName
    End Sub


    Public Sub WriteLine(ByVal strApp As String, ByVal strLine As String)
        Dim objWriter As StreamWriter = New StreamWriter(FileName, True)

        Try
            Dim strPrefix As String = DateTime.UtcNow.ToString("dd/MM/yyyy hh:mm:ss UTC") + " : " + strApp.PadRight(20) + " - "

            strLine = strPrefix + strLine

            strLine = strLine.Replace(vbCrLf, vbCrLf + strPrefix)

            objWriter.WriteLine(strLine)
            objWriter.Flush()


        Catch ex As Exception
            Throw (ex)
        Finally
            objWriter.Close()
            objWriter = Nothing
        End Try
    End Sub

End Class
